package demo.security.core.social.qq.connect;

import demo.security.core.social.qq.api.QQSocial;
import demo.security.core.social.qq.api.QQUserInfo;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;

/**
 * QQAdapter
 *
 * @author lidj
 * @date 2018-02-05
 */
public class QQAdapter implements ApiAdapter<QQSocial> {

    @Override
    public boolean test(QQSocial api) {
        return true;
    }

    @Override
    public void setConnectionValues(QQSocial api, ConnectionValues values) {
        QQUserInfo userInfo = api.getQQUserInfo();
        values.setDisplayName(userInfo.getNickname());
        values.setImageUrl(userInfo.getFigureurl_qq_1());
        values.setProfileUrl(null);
        values.setProviderUserId(userInfo.getOpenId());
    }

    @Override
    public UserProfile fetchUserProfile(QQSocial api) {
        return null;
    }

    @Override
    public void updateStatus(QQSocial api, String message) {
        // do nothing
    }
}
